package com.fancy.learncenter.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.MsgCommentDataBean;
import com.fancy.learncenter.utils.Utils;
import com.journeyapps.barcodescanner.Util;
import com.superservice.lya.R;

import java.util.ArrayList;

/**
 * Created by hyy on 2018/4/25.
 */

public class ReplyCommentAdapter extends CommonRecycleViewAdapter<MsgCommentDataBean> {

    public ReplyCommentAdapter(Context mContext, ArrayList<MsgCommentDataBean> itemDatas) {
        super(mContext, R.layout.activity_reply_comment_item, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final MsgCommentDataBean item, final int position) {
        TextView name = customViewHold.getView(R.id.name);
        name.setText(item.getNick_name());

        TextView content = customViewHold.getView(R.id.content);
        content.setText(item.getContent());

        TextView time = customViewHold.getView(R.id.time);
        time.setText(item.getAdd_time());

        View is_read = customViewHold.getView(R.id.is_read);

        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(item.getImgsrc());

        if (item.getIs_read().equals("0")) {
            is_read.setVisibility(View.VISIBLE);
        } else {
            is_read.setVisibility(View.GONE);
        }

        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                item.setIs_read("1");

                notifyItemChanged(position);

                Utils.goMsgToActivity(item.getType(), item.getRelate_id() + "", mContext);
            }
        });

    }
}
